<template>
<div>
  <h2 :style="{opacity}">React太难了</h2>
  <button @click="bailan">不学了</button>
</div>
</template>

<script>
export default {
    name:"App",
  data(){
      return{
        opacity: 1,
        timerId:null,
      }
  },
  methods:{
      bailan(){
        this.$destroy();
      },
  },
  mounted() {
      this.timerId = setInterval(()=>{
        this.opacity -= 0.15;
        if(this.opacity <=0){
          this.opacity=1;
        }
      },600)
  },
  beforeDestroy() {
      clearInterval(this.timerId)
  }

}
</script>